package com.ksp.wke;

import javax.servlet.ServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ksp.api.KSPAPI_UsrAuth;


@Controller
public class HomeController {

	@RequestMapping(value = {"/", "/index"})
	public String shouwIndex() {
		return "index";
	}
	
	@RequestMapping("/p/{mod}/{pge}")
	public String shouwCustomPage(@PathVariable("mod") String mod, 
			@PathVariable("pge") String pge, ServletRequest request) {
		if ("tsk".equals(mod)) {
			String wLgnUsr = KSPAPI_UsrAuth.getUsr(request);
			if (wLgnUsr == null || wLgnUsr.trim() == "") {
				return "error";
			}
		}
		if ("quit".equals(pge)) {
			KSPAPI_UsrAuth.delUsr(request);
			return "index";
		}
		return pge;
	}
}
